<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #div{
      width:100px;
      height:100px;
      background: #ccc;
      position: absolute;
      left: 0;
      top: 0;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div id="div"></div>
  <script>
    window.onload=function(){
      let myDiv = document.getElementById("div")
      myDiv.onclick=aa
      function aa(){
        let noX = this.offsetLeft
        let noY = this.offsetTop
        let newDisX = parseInt(window.innerWidth*Math.random())
        let newDisY = parseInt(window.innerHeight*Math.random())
        if(newDisX-noX<100){
          newDisX = window.innerWidth - newDisX >100 ? newDisX+100 : newDisX-100 
        }
        if(newDisY-noY<100){
          newDisY = window.innerHeight - newDisY >100 ? newDisY + 100 : newDisY-100
        }
        this.style.left = newDisX + "px"
        this.style.top = newDisY + "px"
      }
    }
  </script>
</body>
</html>